Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: FT.EXPLAIN and FT.EXPLAINCLI #2515

Open
wants to merge 10 commits into
base: release-1.2
Choose a base branch
from

Conversation

cyip10
Copy link
Collaborator

@cyip10 cyip10 commented Oct 24, 2024

Issue link

This Pull Request is linked to issue (URL): #2428

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Commits will be squashed upon merging.

Signed-off-by: Chloe <chloe.yip@improving.com>
Signed-off-by: Chloe Yip <chloe.yip@improving.com>
Signed-off-by: Chloe <chloe.yip@improving.com>
@cyip10 cyip10 added the java issues and fixes related to the java client label Oct 24, 2024
@cyip10 cyip10 requested a review from a team as a code owner October 24, 2024 22:04
Signed-off-by: Chloe <chloe.yip@improving.com>
Signed-off-by: Chloe <chloe.yip@improving.com>
Signed-off-by: Chloe <chloe.yip@improving.com>
Signed-off-by: Chloe <chloe.yip@improving.com>
assertTrue(exception.getMessage().contains("Index not found"));
}

@SneakyThrows
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead, you can throw on the method signature

// search query containing numeric field.
String query = "@price:[0 10]";
String result[] = FT.explaincli(client, indexName, query).get();
List<String> resultList = new ArrayList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an interesting exercise, you can use Stream() to map result to a result list. Something like:

List<String> trimmedResult = result.stream().map(::trim).collect(Collection.toList());

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately streams only work on lists

Copy link
Collaborator

@acarbonetto acarbonetto Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrays.stream() works on arrays. I'll point you to an example, and IntelliJ has a lot of hints to help create streams.

https://github.com/valkey-io/valkey-glide/blob/main/java/client/src/main/java/glide/utils/ArrayTransformUtils.java#L162-L164

assertTrue((resultListGS).contains("0"));
assertTrue((resultListGS).contains("10"));

resultListGS.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use a new variable. memory is cheap

Signed-off-by: Chloe <chloe.yip@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants